home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 27 / IOPROG_27.ISO / SOFT / TDROPFL.ZIP / TDropFile / Demo / Demo Source (Delphi) / Unit1.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1998-02-14  |  1.3 KB  |  62 lines

  1. unit Unit1;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   DropFile, ComCtrls, StdCtrls, ExtCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Memo1: TMemo;
  12.     StatusBar1: TStatusBar;
  13.     DropFile1: TDropFile;
  14.     Panel1: TPanel;
  15.     Image1: TImage;
  16.     Label1: TLabel;
  17.     procedure DropFile1FileDrop(Sender: TObject; Filename: string);
  18.     procedure FormShow(Sender: TObject);
  19.     procedure FormClose(Sender: TObject; var Action: TCloseAction);
  20.   private
  21.     { Private declarations }
  22.   public
  23.     { Public declarations }
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.DFM}
  32.  
  33.  
  34. procedure TForm1.DropFile1FileDrop(Sender: TObject; Filename: string);
  35. var
  36.   F: TextFile;
  37.   S: string;
  38. begin
  39.   memo1.clear;
  40.   AssignFile(F, FileName);   { FileName returned from TDropFile component }
  41.   StatusBar1.SimpleText:= fileName + ' was dropped';
  42.   Reset(F);
  43.   while not EOF(F) do
  44.     begin
  45.       Readln(F, S);          { Read the first line out of the file }
  46.       Memo1.Lines.add(S);    { Put string in a TMemo control }
  47.     end;
  48.   CloseFile(F);
  49. end;
  50.  
  51. procedure TForm1.FormShow(Sender: TObject);
  52. begin
  53.   DropFile1.enableDropFile(form1.handle);
  54. end;
  55.  
  56. procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
  57. begin
  58.   dropFile1.disableDropFile;
  59. end;
  60.  
  61. end.
  62.